package fr.utbm.gl52.smartgrid.model.sources;

import java.util.Map;
import java.util.TreeMap;

import fr.utbm.gl52.smartgrid.util.properties.Properties;
import fr.utbm.gl52.smartgrid.util.properties.PropertyDouble;
import fr.utbm.gl52.smartgrid.util.properties.PropertyLong;

public class FuelCell extends NonRenewableSource {

	private double hydrogenConsumption;
	private double supCaloryConsumption;
	private long numberOfCycles;
	private double consumedHydrogen;

	public FuelCell() {
		super();
	}

	public FuelCell(String name, double power, double current, double voltage,
			double efficiency, double powerMin, double powerMax, long lifespan,
			double dynamic, double dynamicMin, double dynamicMax,
			double supCaloryConsumption) {
		super(name, power, current, voltage, efficiency, powerMin, powerMax,
				lifespan, dynamic, dynamicMin, dynamicMax);
		// TODO Auto-generated constructor stub

		this.hydrogenConsumption = 0;
		this.numberOfCycles = 0;
		this.consumedHydrogen = 0;

		this.supCaloryConsumption = supCaloryConsumption;
	}

	public double getHydrogenConsumption() {
		return this.hydrogenConsumption;
	}

	public void setHydrogenConsumption(double hydrogenConsumption) {
		this.hydrogenConsumption = hydrogenConsumption;
	}

	public double getSupCaloryConsumption() {
		return this.supCaloryConsumption;
	}

	public void setSupCaloryConsumption(double supCaloryConsumption) {
		this.supCaloryConsumption = supCaloryConsumption;
	}

	public long getNumberOfCycles() {
		return this.numberOfCycles;
	}

	public void setNumberOfCycles(int numberOfCycles) {
		this.numberOfCycles = numberOfCycles;
	}

	public double getConsumedHydrogen() {
		return this.consumedHydrogen;
	}

	public void setConsumedHydrogen(double consumedHydrogen) {
		this.consumedHydrogen = consumedHydrogen;
	}

	public Map<String, Properties<?>> getProperties() {
		TreeMap<String, Properties<?>> prop = (TreeMap<String, Properties<?>>) super
				.getProperties();
		PropertyDouble p1 = new PropertyDouble(
				Messages.getString("FuelCell.0"), this.hydrogenConsumption, false); //$NON-NLS-1$
		PropertyDouble p2 = new PropertyDouble(
				Messages.getString("FuelCell.1"), this.supCaloryConsumption, false); //$NON-NLS-1$
		PropertyLong p3 = new PropertyLong(
				Messages.getString("FuelCell.2"), this.numberOfCycles, false); //$NON-NLS-1$
		PropertyDouble p4 = new PropertyDouble(
				Messages.getString("FuelCell.3"), this.consumedHydrogen, false); //$NON-NLS-1$
		prop.put(p1.getName(), p1);
		prop.put(p2.getName(), p2);
		prop.put(p3.getName(), p3);
		prop.put(p4.getName(), p4);
		return prop;

	}

	public void setProperties(Map<String, Properties<?>> map) {
		this.hydrogenConsumption = (Double) map.remove(
				Messages.getString("FuelCell.0")).getValue(); //$NON-NLS-1$
		this.supCaloryConsumption = (Double) map.remove(
				Messages.getString("FuelCell.1")).getValue(); //$NON-NLS-1$
		this.numberOfCycles = (Long) map
				.remove(Messages.getString("FuelCell.2")).getValue(); //$NON-NLS-1$
		this.consumedHydrogen = (Double) map
				.remove(Messages.getString("FuelCell.3")).getValue(); //$NON-NLS-1$
		super.setProperties(map);
	}

}
